/**********************************************
*  Classes:   MeshNode
*  Desc:      Defines a mesh node. Derives 
*			  from GeometryNode. Uses Vertex Buffer
*			  Objects for rendering
*  Author:    Vaios Kalpias-Ilias (C) 2008-2009
***********************************************/

#ifndef MESHNODE_H
#define MESHNODE_H

#include "GeometryNode.h"
#include "Vector.h"
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
#include <gl/glaux.h>
#include "glext.h"

class MeshNode : public GeometryNode
{
public:

	MeshNode();
	~MeshNode();

	// Creates VBO's 
	bool BindToMesh(MathLib::Vector3* vertices,
					MathLib::Vector3* normals,
					MathLib::Vector2* texCoords,
					int numOfVertices);

	// clone mesh
	GeometryNode* Clone();

	const NodeType GetType() const
	{
		return NODE_MESH;
	}

private:

	// Vertex VBO Name
	unsigned int	m_uiVBOVertices;	
	// Normals VBO Name
	unsigned int	m_uiVBONormals;
	// Texture Coordinate VBO Name
	unsigned int	m_uiVBOTexCoords;	
	// number of vertices
	int             m_iNumVertices;


	// renders mesh
	void RenderShape();
	// are VBO's suuported?
	static bool IsVBOExtensionSupported();
	// VBO Extension Function Pointers
	// VBO Name Generation Procedure
	PFNGLGENBUFFERSARBPROC glGenBuffersARB;	
	// VBO Bind Procedure
	PFNGLBINDBUFFERARBPROC glBindBufferARB;			
	// VBO Data Loading Procedure
	PFNGLBUFFERDATAARBPROC glBufferDataARB;		
	// VBO Deletion Procedure
	PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB;
	
};

#endif